package pl.symulatorbiegu;

import junit.framework.TestCase;

import java.util.ArrayList;

/**
 * Created by Lukas on 09.12.13.
 */
public class HeatSimulatorTest extends TestCase {
    HeatSimulatorMock uut;

    public void setUp() throws Exception {
        super.setUp();
       uut = getHeatSimulatorMock();
    }

    public void tearDown() throws Exception {
    }

    public void testSimulateHeat() {
        uut.simulateHeat();
        assertEquals(2.9220096548596435, uut.simulatedValues.get(0));
        assertEquals(2.1949760573477053, uut.simulatedValues.get(1));
        assertEquals(2.46715957265395, uut.simulatedValues.get(2));
        assertEquals(3.0784408674101487, uut.simulatedValues.get(3));

        assertEquals((Integer) 3, uut.sortedMap.get(3.0784408674101487));
        assertEquals((Integer) 0, uut.sortedMap.get(2.9220096548596435));
        assertEquals((Integer) 2, uut.sortedMap.get(2.46715957265395));
        assertEquals((Integer) 1, uut.sortedMap.get(2.1949760573477053));

        assertEquals((Integer) 1, uut.pointsMap.get(0));
        assertEquals((Integer) 2, uut.pointsMap.get(1));
        assertEquals((Integer) 0, uut.pointsMap.get(2));
        assertEquals((Integer) 3, uut.pointsMap.get(3));
    }

    private HeatSimulatorMock getHeatSimulatorMock() {
        ArrayList<Double> values = new ArrayList<Double>(4);
        values.add(2.2);
        values.add(2.0);
        values.add(1.8);
        values.add(2.3);
        return new HeatSimulatorMock(values);
    }

    public void testSetSimulationRange() {
        uut.setSimulationRange(2.0);
        assertEquals(2.0,uut.simulationRange);
    }
}
